<?php
get_header(); ?>

    <div class="col-md-12 column content">
	<div class="row clearfix">
	


		<?php if( have_posts() ) : while ( have_posts() ) : the_post(); ?>
		<?php get_template_part( 'kolompertama' ); ?>
	
    <?php
	
	$chapter_id= isset( $_GET['pid'] ) ? intval( $_GET['pid'] ) : 0;
	
	if ($chapter_id!=0){
			$lala=get_post($chapter_id);
			$ctitle = $lala->post_title;
			$ccontent=$lala->post_content;
			
	}
	 ?>

		<div class="col-md-9 column" > <!-- untuk kolom kedua yang dibagi 2 -->
			<div class="row clearfix">
									
				<div class="col-md-12 column">
				
                	<!-- start cerita -->
                    <div>
					
                        <br/>
                        <h9>
                            <?php if ($chapter_id!=0) {the_title();echo " - " . $ctitle;} else {the_title(); }?> 
                        </h9>
                        <hr/>
                        <table style="width:100%" id="tablepager">
                            <tr>
                                <td style="width:30%">
							<?php	$mykey_values = get_post_custom_values( 'Chapter' );
?>								<form name="selectpart" >
							                              
                                   
									
									<?php  
									if (count($mykey_values) >0){
									$sort = array();
									$idbab = array();
                                foreach ( $mykey_values as $key => $babid ) 
										{
											
											$number = get_post_meta($babid, 'number', true);//get_post_custom_values ( 'number', $babid);
											array_push($sort, (int)$number);
											array_push($idbab, $babid);
										
												
										}
										//sorting chapter berdasarkan urutan (number)
											array_multisort($sort,$idbab); ?>
											<select  class="selectBox" onchange =" window.open( this.options[ this.selectedIndex ].value, '_self')" name="part" width="300px">
								<?php	if ($chapter_id==0){
												echo "<option >&nbsp;&nbsp;Silakan pilih bab&nbsp;&nbsp;&nbsp;&nbsp;</option>";
																							
												} 
										else {echo "<option value='?pid=''>SINOPSIS</option>";
											
											}
											//kalau login dan idlogin == user create ditampilkan draftnya
											// kaau gak login gak ditamplikan
											 foreach ( $idbab as $sortedid => $babidsorted )
											{
											  $chapter = get_post($babidsorted);
												$title = $chapter->post_title;
												$content = $chapter -> post_content;
												$statusbab = $chapter ->post_status;
												$link = "?pid=".$babidsorted . "&" .$title;
												if ($statusbab == 'draft'){
													$authorid = get_post_field( 'post_author', $babidsorted );
													if (is_user_logged_in() && ($authorid == get_current_user_id()))
													{
													 if ($chapter_id==$babidsorted)
													  {	
													  echo "<option selected='selected' 'value='".$link."'>".$title." (Konsep)</value>";
														}
													else {		echo "<option value='".$link."'>".$title." (Konsep)</value>";}
													}
												}
												else {
											
												  if ($chapter_id==$babidsorted)
												  {	
												  echo "<option selected='selected' 'value='".$link."'>".$title."</value>";
													}
												else {		echo "<option value='".$link."'>".$title."</value>";}
												}
											}
										} 
											?>
								
																	
                                      </select>
									   </div>
									 </form>
										

                                </td>
								
                           <!--     <td style="width:10%"></td>
                                <td style="width:6%">
                                    <button type="button" class="btn btn-default"><span class="glyphicon glyphicon-fast-backward"></span></button>
                                    <button type="button" class="btn btn-default"><span class="glyphicon glyphicon-backward"></span></button>
                                </td>
                                <td style="width:0.8%"><input class="form-control pagebuku font10" id="inputPassword3" type="text" value="1 of 100"></td>
                                <td style="width:6%">
                                    <button type="button" class="btn btn-default"><span class="glyphicon glyphicon-forward"></span></button>
                                    <button type="button" class="btn btn-default"><span class="glyphicon glyphicon-fast-forward"></span></button>
                                </td> -->
                            </tr>
                        </table>
                        
                        <br/>
                        <div id="paper"></div> 
                        <div id="page"> 
						
                       <div class="paragrafcerita" id="text-pager"><!--ini yang bikin gagal pagination nya jadi harus tambah div-->
					   <div><?php if ($chapter_id!=0) {  echo wpautop($ccontent) ;
				
					  }
					   else { ?> <h7>SINOPSIS</h7><br/> <hr/>
					   <?php the_content();}?> </div></div>
						<div class="controls" >
						<a class="tp-control-arrow-left unactive" href="#tablepager"><span>Prev</span></a>
						<a class="tp-control-arrow-right" href="#tablepager"><span>Next</span></a>
						<ul class="pager222">
						</ul>
						</div>
						<script>
						//$(window).load(function(){
						$('#text-pager').textpager({
						controlArrows: ".controls",
						controlPages: ".controls .pager222",
						controlPagesContent: "li",
						
						});//});
						$('.tp-page').attr("href") = "#";
						
						
						
						
						</script>
						<br/>
						

						
						
                        </div>
                    </div>
          
                    <div class="clearfix"></div>
                    <hr/>
                   	<div class="font10 abu"><!--<span class="glyphicon glyphicon-heart-empty"></span>&nbsp;&nbsp;&nbsp;12.989 suka&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; --><span class="glyphicon glyphicon-comment"></span>&nbsp;&nbsp;&nbsp;<?php echo get_comments_number( get_the_ID() );?> komentar&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="glyphicon glyphicon-eye-open"></span>&nbsp;&nbsp;&nbsp;<?php the_views(); ?> views</div>
                    <br/>
					
					<table class="col-md-12 column"> 
<tr>				
			<?php /* if(is_user_logged_in()){ 
			
		echo "	 <td  style='color:#fff'> ";
		echo	do_shortcode('[likebtn identifier="post_'.get_the_ID().'" i18n_like_tooltip="klik untuk menyukai" i18n_after_like="batal suka" style="disk" popup_enabled="0" icon_like_show="0" i18n_like="suka" counter_show="0" show_like_label="1"  show_dislike_label="0" dislike_enabled="0"  i18n_after_like="sudah menyukai" ]');
		echo "		 </td> ";
                    }*/ ?>
				<!--	<td  class="btn"> <button type="button" class="btn"><span class="glyphicon glyphicon-comment"></span>&nbsp;&nbsp;komentari</button></td>
                   <td  class="btn">  <button type="button" class="btn"><span class="glyphicon glyphicon-star"></span>&nbsp;&nbsp;vote cerita</button></td>
                    <td  class="btn"> <button type="button" class="btn"><span class="glyphicon glyphicon-star"></span>&nbsp;&nbsp;vote author</button></td> -->
					</tr>
					<tr><td align="right">
					<?php wprc_report_submission_form(); ?> </td></tr><tr><td>
		 <?php 
						comments_template(); //comments.php belum di edit. gmna nehh??
?>				
					
	<?php	 endwhile; endif; ?>
		 </td>
					</tr>
					</table>
                 <!--   <div class="clearfix"></div>
                    <br/>
                    <h9>komentar :</h9>
                    <div class="media well">
                         <a href="#" class="pull-left"><img src="img/foto suri.jpg" class="media-object fotocomment" /></a>
                        <div class="media-body">
                            <div class="coment">
                            Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis.
                            </div>
                            <div class="font2">19 jam lalu | <label>5 suka</label>&nbsp;|&nbsp;<span class="glyphicon glyphicon-heart-empty"></span> </div>
                            <div class="media">
                                 <a href="#" class="pull-left"><img src="img/foto suri.jpg" class="media-object fotocomment" /></a>
                                <div class="media-body coment">
                                    Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis.
                                </div>
                                <div class="font2">19 jam lalu | <label>5 suka</label>&nbsp;|&nbsp;<span class="glyphicon glyphicon-heart-empty"></span></div>
                            </div>
                        </div>
                    </div>
                    
                    <div class="media well">
                         <a href="#" class="pull-left"><img src="img/foto suri.jpg" class="media-object fotocomment" /></a>
                        <div class="media-body">
                            <div class="coment">
                            Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis.
                            </div>
                            <div class="font2">19 jam lalu | <label>5 suka</label>&nbsp;|&nbsp;<span class="glyphicon glyphicon-heart-empty"></span></div>
                            <div class="media">
                                 <a href="#" class="pull-left"><img src="img/foto suri.jpg" class="media-object fotocomment" /></a>
                                <div class="media-body coment">
                                    Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis.
                                </div>
                                <div class="font2">19 jam lalu | <label>5 suka</label>&nbsp;|&nbsp;<span class="glyphicon glyphicon-heart-empty"></span></div>
                            </div>
                            <div class="media">
                                 <a href="#" class="pull-left"><img src="img/foto suri.jpg" class="media-object fotocomment" /></a>
                                <div class="media-body coment">
                                    Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis.
                                </div>
                                <div class="font2">19 jam lalu | <label>5 suka</label>&nbsp;|&nbsp;<span class="glyphicon glyphicon-heart-empty"></span></div>
                            </div>
                        </div>
                    </div>
            		-->
                    <!-- stop cerita -->
                </div>
            </div>
		</div> <!-- end kolom kedua -->
		
       </div><!-- end row clearfix -->
</div> <!--end col-md-12 column content-->
	<!-- end untuk content -->
     <!-- untuk iklan -->
	
    
    <!-- untuk footer -->
	<?php
get_footer();
?>